var t = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../utils/util.js")), a = require("../../../mybehaviors/location/location"), e = getApp();

Page({
    behaviors: [ a ],
    data: {
        Height: 0,
        LastHeight: 0,
        indicatorDots: !0,
        autoplay: !0,
        interval: 5e3,
        duration: 1e3,
        imageurl: [],
        categories: [],
        city: "",
        dataList: [],
        nowTime: "",
        len: "",
        konginp: "",
        kFootshow: !0,
        set: {}
    },
    onLoad: function(t) {
        var a = this;
        if (t.addressData) {
            var e = JSON.parse(t.addressData);
            this.setData({
                "point.lat": e.latitude,
                "point.lng": e.longitude,
                address: e.title,
                title: e.title,
                city: e.city
            }), console.log(JSON.parse(t.addressData));
        } else console.log("2222222222222222"), this._getLocation(function() {
            a.getlist();
        });
        t.message && wx.showToast({
            title: t.message,
            icon: "none",
            duration: 1e3
        }), this.getlist(), this.getbanner(), this.getFl();
    },
    tabrshowbtn: function(t) {
        t.detail && this.setData({
            kFootshow: !1
        });
    },
    goFenlei: function(t) {
        var a = t.currentTarget.dataset.name;
        if ("hot" == a || "poper" == a) {
            var e = t.currentTarget.id;
            wx.navigateTo({
                url: "/packageC/Myshaky/sort/sort?city=" + this.data.city + "&fenl=" + a + "&id=" + e
            });
        } else {
            var i = t.currentTarget.id, n = t.currentTarget.dataset.name;
            wx.navigateTo({
                url: "/packageC/Myshaky/sort/sort?city=" + this.data.city + "&fenl=" + n + "&id=" + i
            });
        }
    },
    tapUrl: function(t) {
        var a = t.currentTarget.dataset.url;
        if ("" == a) return !1;
        try {
            wx.navigateTo({
                url: a
            });
        } catch (t) {
            console.log(t);
        }
    },
    goxq: function(t) {
        var a = t.currentTarget.id;
        wx.navigateTo({
            url: "/packageC/Myshaky/enrollEnter/enrollEnter?id=" + a
        });
    },
    goDw: function(t) {
        wx.navigateTo({
            url: "/packageC/o2o/o2oLocation/o2oLocation?tag=activityHome"
        });
    },
    inpText: function(t) {
        this.setData({
            inpText: t.detail.value
        });
    },
    goSearch: function(t) {
        this.data.inpText ? wx.navigateTo({
            url: "/packageC/Myshaky/searchResult/searchResult?city_name=" + this.data.city + "&keywords=" + this.data.inpText
        }) : wx.navigateTo({
            url: "/packageC/Myshaky/searchResult/searchResult?city_name=" + this.data.city + "&keywords=" + this.data.konginp
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        var t = {};
        return this.data.set && (this.data.set.share_title && (t.title = this.data.set.share_title), 
        this.data.set.share_thumb && (t.imageUrl = this.data.set.share_thumb)), t;
    },
    getlist: function() {
        var a = e.getNetAddresss("plugin.activity-apply.api.index.getActivity"), i = this;
        e._getNetWork({
            url: a,
            data: {
                city_name: i.data.city
            },
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    for (var n = e.data.$recommand, s = Date.parse(new Date()) / 1e3, o = 0; o < n.length; o++) n[o].start_time = t.default.formatTimeTwo(n[o].start_time, "Y/M/D h:m:s");
                    for (var r = e.data.discount, l = 0; l < r.length; l++) r[l].start_time = t.default.formatTimeTwo(r[l].start_time, "M.D"), 
                    r[l].end_time = t.default.formatTimeTwo(r[l].end_time, "M.D");
                    var c = e.data.hot;
                    i.setData({
                        dataList: e.data,
                        hot: c,
                        discount: r,
                        recommand: n,
                        nowTime: s,
                        len: r.length,
                        set: e.data.set
                    });
                }
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    imgHeight: function(t) {
        var a = wx.getSystemInfoSync().windowWidth * t.detail.height / t.detail.width + "px";
        parseInt(a) > this.data.LastHeight && (this.setData({
            Height: a
        }), this.data.LastHeight = parseInt(a));
    },
    getbanner: function() {
        var t = e.getNetAddresss("plugin.activity-apply.api.index.getLantetnSlide"), a = this;
        e._getNetWork({
            url: t,
            success: function(t) {
                var e = t.data;
                1 == e.result && a.setData({
                    imageurl: e.data
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getFl: function() {
        var t = e.getNetAddresss("plugin.activity-apply.api.index.getCalssify"), a = this;
        e._getNetWork({
            url: t,
            success: function(t) {
                var e = t.data;
                1 == e.result && a.setData({
                    categories: e.data.reverse()
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});